//
//  MyselfViewController.m
//  A_GOGO
//
//  Created by Liuiu on 16/1/23.
//  Copyright © 2016年 www.lanou3g.com. All rights reserved.
//

#import "MyselfViewController.h"
#import "NetworkHandler.h"
#import "HomeModel.h"
#import <UIImageView+WebCache.h>
#import "UIColor+Wonderful.h"
#import "LoginViewController.h"

@interface MyselfViewController ()<UIScrollViewDelegate>
@property (nonatomic, retain)UIScrollView *scrollView;
@property (nonatomic, retain)UICollectionView *collection;
@end

@implementation MyselfViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.view.backgroundColor =[UIColor whiteColor];
    
//*********** scrollView
    self.scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    _scrollView.delegate =self;
    _scrollView.backgroundColor =[UIColor gainsboroColor];
    _scrollView.contentSize = CGSizeMake(0, 800);
    [self.view addSubview:_scrollView];
    [_scrollView release];
    
    
#pragma mark - 布置页面
    
    
    [self data];
}
- (void)data
{
    NSString *str =@"http://open.youxiduo.com/user/info/?debug=beta&source=bc9d9f7784910a6766fadf6a267bf753&appname=yxdjqb&uid=6052381&os=ios&version=3.4.0";
    [NetworkHandler GETWithURL:str completion:^(id result) {
        NSDictionary *dic = [NSDictionary dictionary];
        dic = result[@"result"];
        
        
        HomeModel *k = [[HomeModel alloc]init];
        [k setValuesForKeysWithDictionary:dic];
//*******  背景图片
        UIImageView *background = [[UIImageView alloc]initWithFrame:CGRectMake(0, -20, self.view.frame.size.width, 667 / 2 +20 )];
        [background sd_setImageWithURL:[NSURL URLWithString:k.background]];
        [self.scrollView addSubview:background];
        [background release];
        
        UIBlurEffect *b = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
        UIVisualEffectView *bV = [[UIVisualEffectView alloc] initWithEffect:b];
        bV.frame = CGRectMake(0, 0, self.view.frame.size.width, 667 / 2 + 20);
        bV.alpha = 0.9;
        [background addSubview:bV];
        
#pragma mark - 仿导航栏
        UIView *viewj =[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 90)];
        viewj.backgroundColor = [UIColor blackColor];
        viewj.alpha = 0.4;
        [background addSubview:viewj];
        [viewj release];
        
        //个人中心
        UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, 40)];
        title.text = @"个人中心";
        title.center = CGPointMake(375 / 2, 45);
        title.textAlignment = NSTextAlignmentCenter;
        title.textColor = [UIColor whiteColor];
        title.font = [UIFont fontWithName:@"Helvetica-Bold" size:19];
        [self.scrollView addSubview:title];
        [title release];
        
        //注销键
        UIButton *button =[UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(320, 25 , 40, 35);
        [button addTarget:self action:@selector(new:) forControlEvents:UIControlEventTouchUpInside];
        [button setTitle:@"注销" forState:UIControlStateNormal];
        [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
        
        [self.scrollView addSubview:button];
    
        //返回
        UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
        [button1 addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
        button1.frame = CGRectMake(10, 25, 35, 35);
        [button1 setImage:[UIImage imageNamed:@"fanhui"] forState:UIControlStateNormal];
        [self.scrollView addSubview:button1];
        
        UIImageView *imagexian =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 88, 88)];
        imagexian.image = [UIImage imageNamed:@"huan"];
        imagexian.center = CGPointMake(375 / 2, 150);
        [background addSubview:imagexian];
        [imagexian release];
        
        UIImageView *imagetou =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 78, 78)];
        [imagetou sd_setImageWithURL:[NSURL URLWithString:k.avatar]];
        imagetou.center = CGPointMake(375 / 2, 150);
        imagetou.layer.cornerRadius = 39;
        [background addSubview:imagetou];
        [imagetou release];
        
        UIImageView *level =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 26, 28)];
        level.center = CGPointMake(375 / 2 + 22.5, 179);
        level.layer.cornerRadius = 13;
        [level sd_setImageWithURL:[NSURL URLWithString:k.levelImg]];
        [background addSubview:level];
        [level release];
        
        UILabel *name =[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 70, 40)];
        name.text = @"溜溜蛋";
        name.center = CGPointMake(375 / 2, 222);
        name.textColor = [UIColor whiteColor];
        name.textAlignment = NSTextAlignmentCenter;
        name.font =[UIFont fontWithName:@"Helvetica-Bold" size:22];
        [background addSubview:name];
        [name release];
        
        
        
        UILabel *qianming =[[UILabel alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 30)];
        qianming.center = CGPointMake(375/2, 255);
        qianming.textColor = [UIColor whiteColor];
        qianming.textAlignment = NSTextAlignmentCenter;
        qianming.text = k.signature;
        [background addSubview:qianming];
        [qianming release];
        
        UIView *small =[[UIView alloc]initWithFrame:CGRectMake(0, 0, 190, 30)];
        small.layer.cornerRadius = 15;
        small.center = CGPointMake(375 / 2, 295);
        small.backgroundColor = [UIColor blackColor];
        small.alpha = 0.4;
        [background addSubview:small];
        
        UILabel *biao =[[UILabel alloc]initWithFrame:CGRectMake(100, 100, 60, 30)];
        biao.center = CGPointMake(375 / 2 - 50, 295);
        biao.text = @"我的游币";
        biao.font =[UIFont fontWithName:@"Helvetica-Bold" size:15];
        biao.textColor =[UIColor whiteColor];
        [background addSubview:biao];
        [biao release];
        
        UIImageView *moeny =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];
        moeny.image =[UIImage imageNamed:@"qiandai"];
        moeny.center =CGPointMake(375 / 2 + 10, 295);
        [background addSubview:moeny];
        [moeny release];
        
        UILabel *count =[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60, 30)];
        count.text = k.money;
        count.center = CGPointMake(375 / 2 + 41, 295);
        count.textColor =[UIColor whiteColor];
        count.font =[UIFont fontWithName:@"Helvetica-Bold" size:15];
        count.textAlignment = NSTextAlignmentCenter;
        [background addSubview:count];
        [count release];
        
        
        
    }];
}
#pragma mark - 按钮区
- (void)new:(UIButton *)btn
{
    LoginViewController *sec =[[LoginViewController alloc]init];
    UINavigationController *navi =[[UINavigationController alloc]initWithRootViewController:sec];
    [self presentViewController:navi animated:YES completion:^{
        
    }];
    
}
- (void)back:(UIButton *)btn
{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
